package ooday04.demo.Practice01;

public class Test {
    public static void main(String[] args) {
        /*
        Master master=new Master();
        Dog dog=new Dog("小黑",2,"黑");
        Chick chick=new Chick("小红",1,"红");
        Fish fish=new Fish("小蓝",2,"蓝");
        master.feed(dog);
        master.feed(chick);
        master.feed(fish);

         */
        Animal[] animals=new Animal[5];
        animals[0]=new Dog("小黑",2,"黑");
        animals[1]=new Dog("小红",1,"红");
        animals[2]=new Chick("小强",3,"蓝");
        animals[3]=new Chick("小黄",5,"黄");
        animals[4]=new Fish("阿强",3,"绿");
        for (int i=0;i<animals.length;i++){
            System.out.println(animals[i].name);
            animals[i].eat();
            animals[i].drink();
            if (animals[i] instanceof Dog){
                Dog dog=(Dog) animals[i];
                dog.lookHome();
            }
            if (animals[i] instanceof Chick){
                Chick chick=(Chick) animals[i];
                chick.layEgg();
            }
            if (animals[i] instanceof Swim){
                Swim s=(Swim) animals[i];
                s.swim();
            }
        }

    }
}
